# app/services/cache.py
from redis import asyncio as aioredis
from app.config.settings import settings


class CacheManager:
    def __init__(self):
        self.redis = aioredis.from_url(
            settings.REDIS_URL,
            decode_responses=True
        )

    async def get_result(self, key: str):
        return await self.redis.get(key)

    async def set_result(self, key: str, value: str, ex: int = 300):
        await self.redis.setex(key, ex, value)


cache = CacheManager()
